﻿using System;
using System.Xml.Linq;
using NUnit.Framework;

namespace BuzzX8.Xmpp.Test
{
    [TestFixture]
    public abstract class DatagramElementTestBase : StreamElementTestBase
    {
        protected readonly JID FromJid = "from@stanza_test.com";
        protected readonly JID ToJid = "to@stanza_test.com";
        protected readonly object Id = Guid.NewGuid();

        protected XElement CreateDatagramXElement(JID from, JID to, object id)
        {
            return CreateDatagramXElement(ElementName, from, to, id);
        }

        protected XElement CreateDatagramXElement(string name, JID from, JID to, object id)
        {
            return CreateDatagramXElement(name, "", "", from, to, id);
        }

        protected XElement CreateDatagramXElement(string name, string namespaceUri, string namespaceName,  JID from, JID to, object id)
        {
            XElement stanzaElement = CreateXElement(name, namespaceUri, namespaceName);
            if (from != null) stanzaElement.SetAttributeValue("from", from);
            if (to != null) stanzaElement.SetAttributeValue("to", to);
            if (id != null) stanzaElement.SetAttributeValue("id", id);
            return stanzaElement;
        }
    }
}
